{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import sys\n",
    "sys.path.append(os.path.abspath(os.path.join('..')))\n",
    "from ch07_autograd.utils import Scalar, draw_graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 定义计算图\n",
    "w = Scalar(0.3, label='w')\n",
    "wh = Scalar(0.5, label='wh')\n",
    "x1 = Scalar(1., label='x1', requires_grad=False)\n",
    "x2 = Scalar(1., label='x2', requires_grad=False)\n",
    "x3 = Scalar(1., label='x3', requires_grad=False)\n",
    "# 可以将h1，h2，h3理解为隐藏状态\n",
    "# 它们分别表示第一步、第二步、第三步的隐藏状态\n",
    "h1 = w * x1\n",
    "h2 = w * x2 + wh * h1\n",
    "h3 = w * x3 + wh * h2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 2.38.0 (20140413.2041)\n",
       " -->\n",
       "<!-- Title: %3 Pages: 1 -->\n",
       "<svg width=\"172pt\" height=\"180pt\"\n",
       " viewBox=\"0.00 0.00 171.79 180.14\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 176.141)\">\n",
       "<title>%3</title>\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-176.141 167.792,-176.141 167.792,4 -4,4\"/>\n",
       "<!-- 140384907122960backward -->\n",
       "<g id=\"node1\" class=\"node\"><title>140384907122960backward</title>\n",
       "<polygon fill=\"lightgreen\" stroke=\"black\" stroke-width=\"2\" points=\"0,-0.5 0,-59.4219 76.2051,-59.4219 76.2051,-0.5 0,-0.5\"/>\n",
       "<text text-anchor=\"middle\" x=\"38.1025\" y=\"-47.4219\" font-family=\"Menlo\" font-size=\"10.00\">grad=1.00</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" stroke-width=\"2\" points=\"0,-39.7812 76.2051,-39.7812 \"/>\n",
       "<text text-anchor=\"middle\" x=\"38.1025\" y=\"-27.7812\" font-family=\"Menlo\" font-size=\"10.00\">value=0.30</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" stroke-width=\"2\" points=\"0,-20.1406 76.2051,-20.1406 \"/>\n",
       "<text text-anchor=\"middle\" x=\"38.1025\" y=\"-8.14062\" font-family=\"Menlo\" font-size=\"10.00\">w</text>\n",
       "</g>\n",
       "<!-- 140384907449632backward -->\n",
       "<g id=\"node2\" class=\"node\"><title>140384907449632backward</title>\n",
       "<path fill=\"#f0f0f0\" stroke=\"black\" d=\"M57,-112.719C57,-112.719 109.205,-112.719 109.205,-112.719 115.205,-112.719 121.205,-118.719 121.205,-124.719 121.205,-124.719 121.205,-159.641 121.205,-159.641 121.205,-165.641 115.205,-171.641 109.205,-171.641 109.205,-171.641 57,-171.641 57,-171.641 51,-171.641 45,-165.641 45,-159.641 45,-159.641 45,-124.719 45,-124.719 45,-118.719 51,-112.719 57,-112.719\"/>\n",
       "<text text-anchor=\"middle\" x=\"83.1025\" y=\"-159.641\" font-family=\"Menlo\" font-size=\"10.00\">grad=1.00</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"45,-152 121.205,-152 \"/>\n",
       "<text text-anchor=\"middle\" x=\"83.1025\" y=\"-140\" font-family=\"Menlo\" font-size=\"10.00\">value=0.30</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"45,-132.359 121.205,-132.359 \"/>\n",
       "<text text-anchor=\"middle\" x=\"83.1025\" y=\"-120.359\" font-family=\"Menlo\" font-size=\"10.00\">*</text>\n",
       "</g>\n",
       "<!-- 140384907449632backward&#45;&gt;140384907122960backward -->\n",
       "<g id=\"edge2\" class=\"edge\"><title>140384907449632backward&#45;&gt;140384907122960backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M71.3968,-112.509C65.9801,-99.2417 59.4697,-83.2956 53.6481,-69.0367\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"56.77,-67.4235 49.7497,-59.4883 50.2893,-70.0694 56.77,-67.4235\"/>\n",
       "<text text-anchor=\"middle\" x=\"80.96\" y=\"-83.0187\" font-family=\"Menlo\" font-size=\"14.00\">1.00</text>\n",
       "</g>\n",
       "<!-- 140384907449296backward -->\n",
       "<g id=\"node3\" class=\"node\"><title>140384907449296backward</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" cx=\"129.103\" cy=\"-29.9609\" rx=\"34.8795\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"129.103\" y=\"-27.7812\" font-family=\"Menlo\" font-size=\"10.00\">x1=1.00</text>\n",
       "</g>\n",
       "<!-- 140384907449632backward&#45;&gt;140384907449296backward -->\n",
       "<g id=\"edge1\" class=\"edge\"><title>140384907449632backward&#45;&gt;140384907449296backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" stroke-dasharray=\"5,2\" d=\"M95.0684,-112.509C103.64,-91.9703 114.892,-65.0114 122.062,-47.8311\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.graphs.Digraph at 0x7fade89ea790>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 对第一步的隐藏状态进行反向传播\n",
    "h1.backward()\n",
    "draw_graph(h1, 'backward')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 2.38.0 (20140413.2041)\n",
       " -->\n",
       "<!-- Title: %3 Pages: 1 -->\n",
       "<svg width=\"315pt\" height=\"405pt\"\n",
       " viewBox=\"0.00 0.00 314.82 404.58\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 400.578)\">\n",
       "<title>%3</title>\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-400.578 310.817,-400.578 310.817,4 -4,4\"/>\n",
       "<!-- 140384908783136backward -->\n",
       "<g id=\"node1\" class=\"node\"><title>140384908783136backward</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" cx=\"223.103\" cy=\"-142.18\" rx=\"34.8795\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"223.103\" y=\"-140\" font-family=\"Menlo\" font-size=\"10.00\">x2=1.00</text>\n",
       "</g>\n",
       "<!-- 140384907449440backward -->\n",
       "<g id=\"node2\" class=\"node\"><title>140384907449440backward</title>\n",
       "<path fill=\"#f0f0f0\" stroke=\"black\" d=\"M150,-337.156C150,-337.156 202.205,-337.156 202.205,-337.156 208.205,-337.156 214.205,-343.156 214.205,-349.156 214.205,-349.156 214.205,-384.078 214.205,-384.078 214.205,-390.078 208.205,-396.078 202.205,-396.078 202.205,-396.078 150,-396.078 150,-396.078 144,-396.078 138,-390.078 138,-384.078 138,-384.078 138,-349.156 138,-349.156 138,-343.156 144,-337.156 150,-337.156\"/>\n",
       "<text text-anchor=\"middle\" x=\"176.103\" y=\"-384.078\" font-family=\"Menlo\" font-size=\"10.00\">grad=1.00</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"138,-376.438 214.205,-376.438 \"/>\n",
       "<text text-anchor=\"middle\" x=\"176.103\" y=\"-364.438\" font-family=\"Menlo\" font-size=\"10.00\">value=0.45</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"138,-356.797 214.205,-356.797 \"/>\n",
       "<text text-anchor=\"middle\" x=\"176.103\" y=\"-344.797\" font-family=\"Menlo\" font-size=\"10.00\">+</text>\n",
       "</g>\n",
       "<!-- 140384907449200backward -->\n",
       "<g id=\"node5\" class=\"node\"><title>140384907449200backward</title>\n",
       "<path fill=\"#f0f0f0\" stroke=\"black\" d=\"M104,-224.938C104,-224.938 156.205,-224.938 156.205,-224.938 162.205,-224.938 168.205,-230.938 168.205,-236.938 168.205,-236.938 168.205,-271.859 168.205,-271.859 168.205,-277.859 162.205,-283.859 156.205,-283.859 156.205,-283.859 104,-283.859 104,-283.859 98,-283.859 92,-277.859 92,-271.859 92,-271.859 92,-236.938 92,-236.938 92,-230.938 98,-224.938 104,-224.938\"/>\n",
       "<text text-anchor=\"middle\" x=\"130.103\" y=\"-271.859\" font-family=\"Menlo\" font-size=\"10.00\">grad=1.00</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"92,-264.219 168.205,-264.219 \"/>\n",
       "<text text-anchor=\"middle\" x=\"130.103\" y=\"-252.219\" font-family=\"Menlo\" font-size=\"10.00\">value=0.15</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"92,-244.578 168.205,-244.578 \"/>\n",
       "<text text-anchor=\"middle\" x=\"130.103\" y=\"-232.578\" font-family=\"Menlo\" font-size=\"10.00\">*</text>\n",
       "</g>\n",
       "<!-- 140384907449440backward&#45;&gt;140384907449200backward -->\n",
       "<g id=\"edge5\" class=\"edge\"><title>140384907449440backward&#45;&gt;140384907449200backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M164.137,-336.946C158.6,-323.679 151.944,-307.733 145.994,-293.474\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"149.09,-291.806 142.009,-283.926 142.63,-294.502 149.09,-291.806\"/>\n",
       "<text text-anchor=\"middle\" x=\"172.96\" y=\"-307.456\" font-family=\"Menlo\" font-size=\"14.00\">1.00</text>\n",
       "</g>\n",
       "<!-- 140384907449728backward -->\n",
       "<g id=\"node6\" class=\"node\"><title>140384907449728backward</title>\n",
       "<path fill=\"#f0f0f0\" stroke=\"black\" d=\"M198,-224.938C198,-224.938 250.205,-224.938 250.205,-224.938 256.205,-224.938 262.205,-230.938 262.205,-236.938 262.205,-236.938 262.205,-271.859 262.205,-271.859 262.205,-277.859 256.205,-283.859 250.205,-283.859 250.205,-283.859 198,-283.859 198,-283.859 192,-283.859 186,-277.859 186,-271.859 186,-271.859 186,-236.938 186,-236.938 186,-230.938 192,-224.938 198,-224.938\"/>\n",
       "<text text-anchor=\"middle\" x=\"224.103\" y=\"-271.859\" font-family=\"Menlo\" font-size=\"10.00\">grad=1.00</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"186,-264.219 262.205,-264.219 \"/>\n",
       "<text text-anchor=\"middle\" x=\"224.103\" y=\"-252.219\" font-family=\"Menlo\" font-size=\"10.00\">value=0.30</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"186,-244.578 262.205,-244.578 \"/>\n",
       "<text text-anchor=\"middle\" x=\"224.103\" y=\"-232.578\" font-family=\"Menlo\" font-size=\"10.00\">*</text>\n",
       "</g>\n",
       "<!-- 140384907449440backward&#45;&gt;140384907449728backward -->\n",
       "<g id=\"edge6\" class=\"edge\"><title>140384907449440backward&#45;&gt;140384907449728backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M188.589,-336.946C194.366,-323.679 201.311,-307.733 207.521,-293.474\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"210.895,-294.492 211.679,-283.926 204.477,-291.697 210.895,-294.492\"/>\n",
       "<text text-anchor=\"middle\" x=\"219.96\" y=\"-307.456\" font-family=\"Menlo\" font-size=\"14.00\">1.00</text>\n",
       "</g>\n",
       "<!-- 140384907122960backward -->\n",
       "<g id=\"node3\" class=\"node\"><title>140384907122960backward</title>\n",
       "<polygon fill=\"lightgreen\" stroke=\"black\" stroke-width=\"2\" points=\"163,-0.5 163,-59.4219 239.205,-59.4219 239.205,-0.5 163,-0.5\"/>\n",
       "<text text-anchor=\"middle\" x=\"201.103\" y=\"-47.4219\" font-family=\"Menlo\" font-size=\"10.00\">grad=2.50</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" stroke-width=\"2\" points=\"163,-39.7812 239.205,-39.7812 \"/>\n",
       "<text text-anchor=\"middle\" x=\"201.103\" y=\"-27.7812\" font-family=\"Menlo\" font-size=\"10.00\">value=0.30</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" stroke-width=\"2\" points=\"163,-20.1406 239.205,-20.1406 \"/>\n",
       "<text text-anchor=\"middle\" x=\"201.103\" y=\"-8.14062\" font-family=\"Menlo\" font-size=\"10.00\">w</text>\n",
       "</g>\n",
       "<!-- 140384907449632backward -->\n",
       "<g id=\"node4\" class=\"node\"><title>140384907449632backward</title>\n",
       "<path fill=\"#f0f0f0\" stroke=\"black\" d=\"M12,-112.719C12,-112.719 64.2051,-112.719 64.2051,-112.719 70.2051,-112.719 76.2051,-118.719 76.2051,-124.719 76.2051,-124.719 76.2051,-159.641 76.2051,-159.641 76.2051,-165.641 70.2051,-171.641 64.2051,-171.641 64.2051,-171.641 12,-171.641 12,-171.641 6,-171.641 0,-165.641 0,-159.641 0,-159.641 0,-124.719 0,-124.719 0,-118.719 6,-112.719 12,-112.719\"/>\n",
       "<text text-anchor=\"middle\" x=\"38.1025\" y=\"-159.641\" font-family=\"Menlo\" font-size=\"10.00\">grad=1.50</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"0,-152 76.2051,-152 \"/>\n",
       "<text text-anchor=\"middle\" x=\"38.1025\" y=\"-140\" font-family=\"Menlo\" font-size=\"10.00\">value=0.30</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"0,-132.359 76.2051,-132.359 \"/>\n",
       "<text text-anchor=\"middle\" x=\"38.1025\" y=\"-120.359\" font-family=\"Menlo\" font-size=\"10.00\">*</text>\n",
       "</g>\n",
       "<!-- 140384907449632backward&#45;&gt;140384907122960backward -->\n",
       "<g id=\"edge7\" class=\"edge\"><title>140384907449632backward&#45;&gt;140384907122960backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M76.3188,-115.338C99.6347,-99.5723 129.609,-79.3041 154.336,-62.5841\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"156.52,-65.3321 162.844,-56.8312 152.599,-59.5333 156.52,-65.3321\"/>\n",
       "<text text-anchor=\"middle\" x=\"146.96\" y=\"-83.0187\" font-family=\"Menlo\" font-size=\"14.00\">0.50</text>\n",
       "</g>\n",
       "<!-- 140384907449296backward -->\n",
       "<g id=\"node7\" class=\"node\"><title>140384907449296backward</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" cx=\"38.1025\" cy=\"-29.9609\" rx=\"34.8795\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"38.1025\" y=\"-27.7812\" font-family=\"Menlo\" font-size=\"10.00\">x1=1.00</text>\n",
       "</g>\n",
       "<!-- 140384907449632backward&#45;&gt;140384907449296backward -->\n",
       "<g id=\"edge4\" class=\"edge\"><title>140384907449632backward&#45;&gt;140384907449296backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" stroke-dasharray=\"5,2\" d=\"M38.1025,-112.509C38.1025,-92.0979 38.1025,-65.346 38.1025,-48.1524\"/>\n",
       "</g>\n",
       "<!-- 140384907449200backward&#45;&gt;140384907449632backward -->\n",
       "<g id=\"edge1\" class=\"edge\"><title>140384907449200backward&#45;&gt;140384907449632backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M106.171,-224.727C94.6708,-210.95 80.7593,-194.284 68.5176,-179.618\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"71.0095,-177.141 61.9145,-171.707 65.6356,-181.627 71.0095,-177.141\"/>\n",
       "<text text-anchor=\"middle\" x=\"106.96\" y=\"-195.238\" font-family=\"Menlo\" font-size=\"14.00\">0.50</text>\n",
       "</g>\n",
       "<!-- 140384908780016backward -->\n",
       "<g id=\"node8\" class=\"node\"><title>140384908780016backward</title>\n",
       "<polygon fill=\"lightgreen\" stroke=\"black\" stroke-width=\"2\" points=\"94,-112.719 94,-171.641 170.205,-171.641 170.205,-112.719 94,-112.719\"/>\n",
       "<text text-anchor=\"middle\" x=\"132.103\" y=\"-159.641\" font-family=\"Menlo\" font-size=\"10.00\">grad=0.30</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" stroke-width=\"2\" points=\"94,-152 170.205,-152 \"/>\n",
       "<text text-anchor=\"middle\" x=\"132.103\" y=\"-140\" font-family=\"Menlo\" font-size=\"10.00\">value=0.50</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" stroke-width=\"2\" points=\"94,-132.359 170.205,-132.359 \"/>\n",
       "<text text-anchor=\"middle\" x=\"132.103\" y=\"-120.359\" font-family=\"Menlo\" font-size=\"10.00\">wh</text>\n",
       "</g>\n",
       "<!-- 140384907449200backward&#45;&gt;140384908780016backward -->\n",
       "<g id=\"edge3\" class=\"edge\"><title>140384907449200backward&#45;&gt;140384908780016backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M130.623,-224.727C130.859,-211.716 131.142,-196.127 131.397,-182.08\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"134.903,-181.769 131.585,-171.707 127.904,-181.642 134.903,-181.769\"/>\n",
       "<text text-anchor=\"middle\" x=\"148.96\" y=\"-195.238\" font-family=\"Menlo\" font-size=\"14.00\">0.30</text>\n",
       "</g>\n",
       "<!-- 140384907449728backward&#45;&gt;140384908783136backward -->\n",
       "<g id=\"edge2\" class=\"edge\"><title>140384907449728backward&#45;&gt;140384908783136backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" stroke-dasharray=\"5,2\" d=\"M223.842,-224.727C223.657,-204.317 223.415,-177.565 223.259,-160.371\"/>\n",
       "</g>\n",
       "<!-- 140384907449728backward&#45;&gt;140384907122960backward -->\n",
       "<g id=\"edge8\" class=\"edge\"><title>140384907449728backward&#45;&gt;140384907122960backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M243.708,-224.704C252.751,-209.745 262.487,-190.729 267.103,-172.141 273.52,-146.293 276.011,-137.317 267.103,-112.219 261.263,-95.7657 250.512,-80.2187 239.359,-67.2145\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"241.686,-64.567 232.402,-59.4608 236.475,-69.2416 241.686,-64.567\"/>\n",
       "<text text-anchor=\"middle\" x=\"289.96\" y=\"-139.128\" font-family=\"Menlo\" font-size=\"14.00\">1.00</text>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.graphs.Digraph at 0x7fade89ea9d0>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 对第二步的隐藏状态进行反向传播\n",
    "h2.backward()\n",
    "draw_graph(h2, 'backward')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 2.38.0 (20140413.2041)\n",
       " -->\n",
       "<!-- Title: %3 Pages: 1 -->\n",
       "<svg width=\"444pt\" height=\"629pt\"\n",
       " viewBox=\"0.00 0.00 443.80 629.02\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 625.016)\">\n",
       "<title>%3</title>\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-625.016 439.802,-625.016 439.802,4 -4,4\"/>\n",
       "<!-- 140384908783136backward -->\n",
       "<g id=\"node1\" class=\"node\"><title>140384908783136backward</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" cx=\"87.1131\" cy=\"-142.18\" rx=\"34.8795\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"87.1131\" y=\"-140\" font-family=\"Menlo\" font-size=\"10.00\">x2=1.00</text>\n",
       "</g>\n",
       "<!-- 140384907449392backward -->\n",
       "<g id=\"node2\" class=\"node\"><title>140384907449392backward</title>\n",
       "<path fill=\"#f0f0f0\" stroke=\"black\" d=\"M326.011,-449.375C326.011,-449.375 378.216,-449.375 378.216,-449.375 384.216,-449.375 390.216,-455.375 390.216,-461.375 390.216,-461.375 390.216,-496.297 390.216,-496.297 390.216,-502.297 384.216,-508.297 378.216,-508.297 378.216,-508.297 326.011,-508.297 326.011,-508.297 320.011,-508.297 314.011,-502.297 314.011,-496.297 314.011,-496.297 314.011,-461.375 314.011,-461.375 314.011,-455.375 320.011,-449.375 326.011,-449.375\"/>\n",
       "<text text-anchor=\"middle\" x=\"352.113\" y=\"-496.297\" font-family=\"Menlo\" font-size=\"10.00\">grad=1.00</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"314.011,-488.656 390.216,-488.656 \"/>\n",
       "<text text-anchor=\"middle\" x=\"352.113\" y=\"-476.656\" font-family=\"Menlo\" font-size=\"10.00\">value=0.30</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"314.011,-469.016 390.216,-469.016 \"/>\n",
       "<text text-anchor=\"middle\" x=\"352.113\" y=\"-457.016\" font-family=\"Menlo\" font-size=\"10.00\">*</text>\n",
       "</g>\n",
       "<!-- 140384907449584backward -->\n",
       "<g id=\"node6\" class=\"node\"><title>140384907449584backward</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" cx=\"401.113\" cy=\"-366.617\" rx=\"34.8795\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"401.113\" y=\"-364.438\" font-family=\"Menlo\" font-size=\"10.00\">x3=1.00</text>\n",
       "</g>\n",
       "<!-- 140384907449392backward&#45;&gt;140384907449584backward -->\n",
       "<g id=\"edge10\" class=\"edge\"><title>140384907449392backward&#45;&gt;140384907449584backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" stroke-dasharray=\"5,2\" d=\"M364.859,-449.165C373.99,-428.627 385.975,-401.668 393.613,-384.487\"/>\n",
       "</g>\n",
       "<!-- 140384907122960backward -->\n",
       "<g id=\"node7\" class=\"node\"><title>140384907122960backward</title>\n",
       "<polygon fill=\"lightgreen\" stroke=\"black\" stroke-width=\"2\" points=\"200.011,-0.5 200.011,-59.4219 276.216,-59.4219 276.216,-0.5 200.011,-0.5\"/>\n",
       "<text text-anchor=\"middle\" x=\"238.113\" y=\"-47.4219\" font-family=\"Menlo\" font-size=\"10.00\">grad=4.25</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" stroke-width=\"2\" points=\"200.011,-39.7812 276.216,-39.7812 \"/>\n",
       "<text text-anchor=\"middle\" x=\"238.113\" y=\"-27.7812\" font-family=\"Menlo\" font-size=\"10.00\">value=0.30</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" stroke-width=\"2\" points=\"200.011,-20.1406 276.216,-20.1406 \"/>\n",
       "<text text-anchor=\"middle\" x=\"238.113\" y=\"-8.14062\" font-family=\"Menlo\" font-size=\"10.00\">w</text>\n",
       "</g>\n",
       "<!-- 140384907449392backward&#45;&gt;140384907122960backward -->\n",
       "<g id=\"edge4\" class=\"edge\"><title>140384907449392backward&#45;&gt;140384907122960backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M346.419,-448.955C342.543,-426.795 338.113,-395.393 338.113,-367.617 338.113,-367.617 338.113,-367.617 338.113,-141.18 338.113,-106.675 310.899,-78.1755 284.865,-58.806\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"286.666,-55.7915 276.49,-52.8419 282.605,-61.4936 286.666,-55.7915\"/>\n",
       "<text text-anchor=\"middle\" x=\"354.97\" y=\"-251.347\" font-family=\"Menlo\" font-size=\"14.00\">1.00</text>\n",
       "</g>\n",
       "<!-- 140384907449440backward -->\n",
       "<g id=\"node3\" class=\"node\"><title>140384907449440backward</title>\n",
       "<path fill=\"#f0f0f0\" stroke=\"black\" d=\"M174.011,-337.156C174.011,-337.156 226.216,-337.156 226.216,-337.156 232.216,-337.156 238.216,-343.156 238.216,-349.156 238.216,-349.156 238.216,-384.078 238.216,-384.078 238.216,-390.078 232.216,-396.078 226.216,-396.078 226.216,-396.078 174.011,-396.078 174.011,-396.078 168.011,-396.078 162.011,-390.078 162.011,-384.078 162.011,-384.078 162.011,-349.156 162.011,-349.156 162.011,-343.156 168.011,-337.156 174.011,-337.156\"/>\n",
       "<text text-anchor=\"middle\" x=\"200.113\" y=\"-384.078\" font-family=\"Menlo\" font-size=\"10.00\">grad=1.50</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"162.011,-376.438 238.216,-376.438 \"/>\n",
       "<text text-anchor=\"middle\" x=\"200.113\" y=\"-364.438\" font-family=\"Menlo\" font-size=\"10.00\">value=0.45</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"162.011,-356.797 238.216,-356.797 \"/>\n",
       "<text text-anchor=\"middle\" x=\"200.113\" y=\"-344.797\" font-family=\"Menlo\" font-size=\"10.00\">+</text>\n",
       "</g>\n",
       "<!-- 140384907449200backward -->\n",
       "<g id=\"node9\" class=\"node\"><title>140384907449200backward</title>\n",
       "<path fill=\"#f0f0f0\" stroke=\"black\" d=\"M174.011,-224.938C174.011,-224.938 226.216,-224.938 226.216,-224.938 232.216,-224.938 238.216,-230.938 238.216,-236.938 238.216,-236.938 238.216,-271.859 238.216,-271.859 238.216,-277.859 232.216,-283.859 226.216,-283.859 226.216,-283.859 174.011,-283.859 174.011,-283.859 168.011,-283.859 162.011,-277.859 162.011,-271.859 162.011,-271.859 162.011,-236.938 162.011,-236.938 162.011,-230.938 168.011,-224.938 174.011,-224.938\"/>\n",
       "<text text-anchor=\"middle\" x=\"200.113\" y=\"-271.859\" font-family=\"Menlo\" font-size=\"10.00\">grad=1.50</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"162.011,-264.219 238.216,-264.219 \"/>\n",
       "<text text-anchor=\"middle\" x=\"200.113\" y=\"-252.219\" font-family=\"Menlo\" font-size=\"10.00\">value=0.15</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"162.011,-244.578 238.216,-244.578 \"/>\n",
       "<text text-anchor=\"middle\" x=\"200.113\" y=\"-232.578\" font-family=\"Menlo\" font-size=\"10.00\">*</text>\n",
       "</g>\n",
       "<!-- 140384907449440backward&#45;&gt;140384907449200backward -->\n",
       "<g id=\"edge11\" class=\"edge\"><title>140384907449440backward&#45;&gt;140384907449200backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M200.113,-336.946C200.113,-323.934 200.113,-308.345 200.113,-294.299\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"203.613,-293.926 200.113,-283.926 196.613,-293.926 203.613,-293.926\"/>\n",
       "<text text-anchor=\"middle\" x=\"216.97\" y=\"-307.456\" font-family=\"Menlo\" font-size=\"14.00\">0.50</text>\n",
       "</g>\n",
       "<!-- 140384907449728backward -->\n",
       "<g id=\"node10\" class=\"node\"><title>140384907449728backward</title>\n",
       "<path fill=\"#f0f0f0\" stroke=\"black\" d=\"M61.0105,-224.938C61.0105,-224.938 113.216,-224.938 113.216,-224.938 119.216,-224.938 125.216,-230.938 125.216,-236.938 125.216,-236.938 125.216,-271.859 125.216,-271.859 125.216,-277.859 119.216,-283.859 113.216,-283.859 113.216,-283.859 61.0105,-283.859 61.0105,-283.859 55.0105,-283.859 49.0105,-277.859 49.0105,-271.859 49.0105,-271.859 49.0105,-236.938 49.0105,-236.938 49.0105,-230.938 55.0105,-224.938 61.0105,-224.938\"/>\n",
       "<text text-anchor=\"middle\" x=\"87.1131\" y=\"-271.859\" font-family=\"Menlo\" font-size=\"10.00\">grad=1.50</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"49.0105,-264.219 125.216,-264.219 \"/>\n",
       "<text text-anchor=\"middle\" x=\"87.1131\" y=\"-252.219\" font-family=\"Menlo\" font-size=\"10.00\">value=0.30</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"49.0105,-244.578 125.216,-244.578 \"/>\n",
       "<text text-anchor=\"middle\" x=\"87.1131\" y=\"-232.578\" font-family=\"Menlo\" font-size=\"10.00\">*</text>\n",
       "</g>\n",
       "<!-- 140384907449440backward&#45;&gt;140384907449728backward -->\n",
       "<g id=\"edge9\" class=\"edge\"><title>140384907449440backward&#45;&gt;140384907449728backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M170.719,-336.946C156.332,-322.914 138.873,-305.884 123.638,-291.024\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"125.963,-288.403 116.36,-283.926 121.075,-293.414 125.963,-288.403\"/>\n",
       "<text text-anchor=\"middle\" x=\"167.97\" y=\"-307.456\" font-family=\"Menlo\" font-size=\"14.00\">0.50</text>\n",
       "</g>\n",
       "<!-- 140384907449488backward -->\n",
       "<g id=\"node4\" class=\"node\"><title>140384907449488backward</title>\n",
       "<path fill=\"#f0f0f0\" stroke=\"black\" d=\"M232.011,-449.375C232.011,-449.375 284.216,-449.375 284.216,-449.375 290.216,-449.375 296.216,-455.375 296.216,-461.375 296.216,-461.375 296.216,-496.297 296.216,-496.297 296.216,-502.297 290.216,-508.297 284.216,-508.297 284.216,-508.297 232.011,-508.297 232.011,-508.297 226.011,-508.297 220.011,-502.297 220.011,-496.297 220.011,-496.297 220.011,-461.375 220.011,-461.375 220.011,-455.375 226.011,-449.375 232.011,-449.375\"/>\n",
       "<text text-anchor=\"middle\" x=\"258.113\" y=\"-496.297\" font-family=\"Menlo\" font-size=\"10.00\">grad=1.00</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"220.011,-488.656 296.216,-488.656 \"/>\n",
       "<text text-anchor=\"middle\" x=\"258.113\" y=\"-476.656\" font-family=\"Menlo\" font-size=\"10.00\">value=0.22</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"220.011,-469.016 296.216,-469.016 \"/>\n",
       "<text text-anchor=\"middle\" x=\"258.113\" y=\"-457.016\" font-family=\"Menlo\" font-size=\"10.00\">*</text>\n",
       "</g>\n",
       "<!-- 140384907449488backward&#45;&gt;140384907449440backward -->\n",
       "<g id=\"edge8\" class=\"edge\"><title>140384907449488backward&#45;&gt;140384907449440backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M240.712,-449.251C237.2,-443.236 233.605,-436.89 230.398,-430.875 226.07,-422.756 221.658,-413.919 217.589,-405.495\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"220.629,-403.738 213.164,-396.22 214.311,-406.752 220.629,-403.738\"/>\n",
       "<text text-anchor=\"middle\" x=\"247.97\" y=\"-419.675\" font-family=\"Menlo\" font-size=\"14.00\">0.50</text>\n",
       "</g>\n",
       "<!-- 140384908780016backward -->\n",
       "<g id=\"node12\" class=\"node\"><title>140384908780016backward</title>\n",
       "<polygon fill=\"lightgreen\" stroke=\"black\" stroke-width=\"2\" points=\"234.011,-112.719 234.011,-171.641 310.216,-171.641 310.216,-112.719 234.011,-112.719\"/>\n",
       "<text text-anchor=\"middle\" x=\"272.113\" y=\"-159.641\" font-family=\"Menlo\" font-size=\"10.00\">grad=0.90</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" stroke-width=\"2\" points=\"234.011,-152 310.216,-152 \"/>\n",
       "<text text-anchor=\"middle\" x=\"272.113\" y=\"-140\" font-family=\"Menlo\" font-size=\"10.00\">value=0.50</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" stroke-width=\"2\" points=\"234.011,-132.359 310.216,-132.359 \"/>\n",
       "<text text-anchor=\"middle\" x=\"272.113\" y=\"-120.359\" font-family=\"Menlo\" font-size=\"10.00\">wh</text>\n",
       "</g>\n",
       "<!-- 140384907449488backward&#45;&gt;140384908780016backward -->\n",
       "<g id=\"edge1\" class=\"edge\"><title>140384907449488backward&#45;&gt;140384908780016backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M262.247,-449.074C262.98,-443.071 263.655,-436.775 264.113,-430.875 271.013,-341.954 272.18,-237.168 272.255,-181.87\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"275.754,-181.814 272.257,-171.813 268.754,-181.812 275.754,-181.814\"/>\n",
       "<text text-anchor=\"middle\" x=\"287.97\" y=\"-307.456\" font-family=\"Menlo\" font-size=\"14.00\">0.45</text>\n",
       "</g>\n",
       "<!-- 140384907449536backward -->\n",
       "<g id=\"node5\" class=\"node\"><title>140384907449536backward</title>\n",
       "<path fill=\"#f0f0f0\" stroke=\"black\" d=\"M283.011,-561.594C283.011,-561.594 335.216,-561.594 335.216,-561.594 341.216,-561.594 347.216,-567.594 347.216,-573.594 347.216,-573.594 347.216,-608.516 347.216,-608.516 347.216,-614.516 341.216,-620.516 335.216,-620.516 335.216,-620.516 283.011,-620.516 283.011,-620.516 277.011,-620.516 271.011,-614.516 271.011,-608.516 271.011,-608.516 271.011,-573.594 271.011,-573.594 271.011,-567.594 277.011,-561.594 283.011,-561.594\"/>\n",
       "<text text-anchor=\"middle\" x=\"309.113\" y=\"-608.516\" font-family=\"Menlo\" font-size=\"10.00\">grad=1.00</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"271.011,-600.875 347.216,-600.875 \"/>\n",
       "<text text-anchor=\"middle\" x=\"309.113\" y=\"-588.875\" font-family=\"Menlo\" font-size=\"10.00\">value=0.52</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"271.011,-581.234 347.216,-581.234 \"/>\n",
       "<text text-anchor=\"middle\" x=\"309.113\" y=\"-569.234\" font-family=\"Menlo\" font-size=\"10.00\">+</text>\n",
       "</g>\n",
       "<!-- 140384907449536backward&#45;&gt;140384907449392backward -->\n",
       "<g id=\"edge12\" class=\"edge\"><title>140384907449536backward&#45;&gt;140384907449392backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M320.299,-561.384C325.474,-548.117 331.696,-532.171 337.258,-517.912\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"340.61,-518.952 340.984,-508.363 334.088,-516.407 340.61,-518.952\"/>\n",
       "<text text-anchor=\"middle\" x=\"349.97\" y=\"-531.894\" font-family=\"Menlo\" font-size=\"14.00\">1.00</text>\n",
       "</g>\n",
       "<!-- 140384907449536backward&#45;&gt;140384907449488backward -->\n",
       "<g id=\"edge7\" class=\"edge\"><title>140384907449536backward&#45;&gt;140384907449488backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M295.847,-561.384C289.649,-547.989 282.187,-531.864 275.541,-517.501\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"278.689,-515.969 271.313,-508.363 272.336,-518.909 278.689,-515.969\"/>\n",
       "<text text-anchor=\"middle\" x=\"302.97\" y=\"-531.894\" font-family=\"Menlo\" font-size=\"14.00\">1.00</text>\n",
       "</g>\n",
       "<!-- 140384907449632backward -->\n",
       "<g id=\"node8\" class=\"node\"><title>140384907449632backward</title>\n",
       "<path fill=\"#f0f0f0\" stroke=\"black\" d=\"M152.011,-112.719C152.011,-112.719 204.216,-112.719 204.216,-112.719 210.216,-112.719 216.216,-118.719 216.216,-124.719 216.216,-124.719 216.216,-159.641 216.216,-159.641 216.216,-165.641 210.216,-171.641 204.216,-171.641 204.216,-171.641 152.011,-171.641 152.011,-171.641 146.011,-171.641 140.011,-165.641 140.011,-159.641 140.011,-159.641 140.011,-124.719 140.011,-124.719 140.011,-118.719 146.011,-112.719 152.011,-112.719\"/>\n",
       "<text text-anchor=\"middle\" x=\"178.113\" y=\"-159.641\" font-family=\"Menlo\" font-size=\"10.00\">grad=1.75</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"140.011,-152 216.216,-152 \"/>\n",
       "<text text-anchor=\"middle\" x=\"178.113\" y=\"-140\" font-family=\"Menlo\" font-size=\"10.00\">value=0.30</text>\n",
       "<polyline fill=\"none\" stroke=\"black\" points=\"140.011,-132.359 216.216,-132.359 \"/>\n",
       "<text text-anchor=\"middle\" x=\"178.113\" y=\"-120.359\" font-family=\"Menlo\" font-size=\"10.00\">*</text>\n",
       "</g>\n",
       "<!-- 140384907449632backward&#45;&gt;140384907122960backward -->\n",
       "<g id=\"edge13\" class=\"edge\"><title>140384907449632backward&#45;&gt;140384907122960backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M193.721,-112.509C201.012,-99.1141 209.791,-82.9887 217.609,-68.6258\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"220.876,-69.9447 222.584,-59.4883 214.728,-66.5979 220.876,-69.9447\"/>\n",
       "<text text-anchor=\"middle\" x=\"228.97\" y=\"-83.0187\" font-family=\"Menlo\" font-size=\"14.00\">0.25</text>\n",
       "</g>\n",
       "<!-- 140384907449296backward -->\n",
       "<g id=\"node11\" class=\"node\"><title>140384907449296backward</title>\n",
       "<ellipse fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" cx=\"147.113\" cy=\"-29.9609\" rx=\"34.8795\" ry=\"18\"/>\n",
       "<text text-anchor=\"middle\" x=\"147.113\" y=\"-27.7812\" font-family=\"Menlo\" font-size=\"10.00\">x1=1.00</text>\n",
       "</g>\n",
       "<!-- 140384907449632backward&#45;&gt;140384907449296backward -->\n",
       "<g id=\"edge6\" class=\"edge\"><title>140384907449632backward&#45;&gt;140384907449296backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" stroke-dasharray=\"5,2\" d=\"M170.049,-112.509C164.272,-91.9703 156.69,-65.0114 151.858,-47.8311\"/>\n",
       "</g>\n",
       "<!-- 140384907449200backward&#45;&gt;140384907449632backward -->\n",
       "<g id=\"edge2\" class=\"edge\"><title>140384907449200backward&#45;&gt;140384907449632backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M180.824,-224.849C177.757,-218.99 175.053,-212.694 173.398,-206.438 171.339,-198.652 170.841,-190.153 171.18,-181.983\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"174.678,-182.141 172.003,-171.89 167.702,-181.572 174.678,-182.141\"/>\n",
       "<text text-anchor=\"middle\" x=\"190.97\" y=\"-195.238\" font-family=\"Menlo\" font-size=\"14.00\">0.25</text>\n",
       "</g>\n",
       "<!-- 140384907449200backward&#45;&gt;140384908780016backward -->\n",
       "<g id=\"edge5\" class=\"edge\"><title>140384907449200backward&#45;&gt;140384908780016backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M211.765,-224.768C216.836,-213.584 223.256,-200.891 230.398,-190.141 232.74,-186.615 235.331,-183.079 238.041,-179.617\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"240.888,-181.665 244.521,-171.712 235.475,-177.227 240.888,-181.665\"/>\n",
       "<text text-anchor=\"middle\" x=\"247.97\" y=\"-195.238\" font-family=\"Menlo\" font-size=\"14.00\">0.15</text>\n",
       "</g>\n",
       "<!-- 140384907449728backward&#45;&gt;140384908783136backward -->\n",
       "<g id=\"edge3\" class=\"edge\"><title>140384907449728backward&#45;&gt;140384908783136backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" stroke-dasharray=\"5,2\" d=\"M87.1131,-224.727C87.1131,-204.317 87.1131,-177.565 87.1131,-160.371\"/>\n",
       "</g>\n",
       "<!-- 140384907449728backward&#45;&gt;140384907122960backward -->\n",
       "<g id=\"edge14\" class=\"edge\"><title>140384907449728backward&#45;&gt;140384907122960backward</title>\n",
       "<path fill=\"none\" stroke=\"deepskyblue\" d=\"M52.3477,-224.92C20.5003,-195.347 -17.8616,-148.43 9.39822,-112.219 58.0667,-47.5683 110.223,-90.4368 190.439,-59.5958\"/>\n",
       "<polygon fill=\"deepskyblue\" stroke=\"deepskyblue\" points=\"191.947,-62.7592 199.84,-55.6912 189.262,-56.2947 191.947,-62.7592\"/>\n",
       "<text text-anchor=\"middle\" x=\"26.9705\" y=\"-139.128\" font-family=\"Menlo\" font-size=\"14.00\">0.50</text>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.graphs.Digraph at 0x7fade89eaeb0>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 对第三步的隐藏状态进行反向传播\n",
    "h3.backward()\n",
    "draw_graph(h3, 'backward')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
